home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / THIN C 2.0 / Projects / nextPrime / nextPrime.c next >
Encoding:
C/C++ Source or Header  |  1991-05-03  |  457 b   |  29 lines  |  [TEXT/THIN]

  1. #include <stdio.h>
  2.  
  3.  
  4. main()
  5. {
  6.     int        startingPoint, candidate, i;
  7.     int        done, foundFactor;
  8.     
  9.     done = FALSE;
  10.     startingPoint = 19;
  11.     candidate = startingPoint;
  12.     
  13.     while ( ! done )
  14.     {
  15.         candidate++;
  16.         
  17.         foundFactor = FALSE;
  18.         for ( i = 2; i < candidate; i++ )
  19.         {
  20.             if ( (candidate / i) * i == candidate )
  21.                 foundFactor = TRUE;
  22.         }
  23.         
  24.         done = (foundFactor == FALSE);
  25.     }
  26.     
  27.     printf( "The next prime after %d is %d.  Happy?",
  28.                     startingPoint, candidate );
  29. }